/**
 * Project Name:youba
 * Package Name:com.inoneone.youba.mcht.util
 * Date:2017/6/21下午1:25
 * Copyright (c) 2017, www.zbj.com All Rights Reserved
 */
package com.inoneone.youba.mcht.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * Description: (描述) </br>
 * Date: 2017/6/21下午1:25 </br>
 *
 * @author 姬远玄
 * @since JDK 1.7
 */
public class CustomDecimalSerialize extends JsonSerializer<BigDecimal> {

    private DecimalFormat df = new DecimalFormat("0.00");

    @Override
    public void serialize(BigDecimal value, JsonGenerator jgen,
                          SerializerProvider provider) throws IOException {
        jgen.writeString(df.format(value));
    }
}
